package com.brillilab.service.module.message.template.impl.topic;

import com.alibaba.fastjson.JSONObject;
import com.brillilab.service.module.message.template.AbstractMessageTemplate;
import com.brillilab.service.module.message.template.enums.MessageTypeEnum;
import lombok.Data;

/**
 * @author zlb
 * @Title: TargetToOtherMemberTemp
 * @ProjectName brill_lab
 * @Description: 实验目标被指派给其他成员-模板
 * @date 2019/5/28 9:30
 */
@Data
public class TargetToOtherMemberTemp extends AbstractMessageTemplate {
    private String targetName;
//    private Long experimentTargetId;
//    private Long executorId;
    /**
     * 课题ID
     */
    private Long topicId;
    /**
     * 课题状态
     */
    private Integer topicState;
    /**
     * 研究内容ID
     */
    private Long topicDirectionId;
    /**
     * 课题目标ID
     */
    private Long topicTargetId;

    /**
     * 实验目标被指派给其他成员时
     *
     * @param labId        实验室ID
     * @param receiverId   接收人ID
     * @param labMemberId  接收者实验室成员Id
     * @param operatorName 操作成员姓名
     * @param targetName   实验目标名称
     * @param referId      业务关联ID
     */
    public TargetToOtherMemberTemp(Long labId, Long receiverId, Long labMemberId, Long referId, String operatorName, String targetName, Integer topicState,Long topicDirectionId,Long topicTargetId) {
        super(labId, receiverId);
        super.setType(MessageTypeEnum.TargetToOtherMember.getValue());
        super.setTitle("您被指派了一个实验目标");
        //#实验目标名称#被指派给了您"
        //#操作成员姓名#指派了#实验目标名称#实验给您
        String content = String.format(
                "<span style='color:#F6AC2D'>%s</span><span>指派了</span>" + "<span style='color:#F6AC2D'>%s</span>" + "<span>实验给您</span>"
                , operatorName, targetName);
        super.setContent(content);
        super.setAppContent(String.format("%s指派了%s实验给您", operatorName, targetName));
        this.labMemberId = labMemberId;
        this.targetName = targetName;
        this.referId = referId;
//        this.experimentTargetId = referId;
//        this.executorId = labMemberId;
        this.topicState = topicState;
        this.topicId=referId;
        this.topicDirectionId=topicDirectionId;
        this.topicTargetId=topicTargetId;
    }

    @Override
    public String getJsonData() {
        JSONObject object = new JSONObject();
//        object.put("experimentTargetId", experimentTargetId);
//        object.put("executorId", executorId);
        object.put("topicId", topicId);
        object.put("topicDirectionId", topicDirectionId);
        object.put("topicState", topicState);
        object.put("topicTargetId", topicTargetId);
        object.put("content",appContent);//app推送需必须加入此参数
        return object.toJSONString();
    }

}
